package com.example.domain;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

public class DBListener extends AnalysisEventListener<Provider> {
    private final static Logger logger = LoggerFactory.getLogger(DBListener.class);

    public static List<Provider> data = new ArrayList<>();

    @Override
    public void invoke(Provider provider, AnalysisContext analysisContext) {
        System.out.println(provider);
        data.add(provider);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        logger.info("Excel信息已全部被读取");
    }

    public static List<Provider> getData() {
        return data;
    }
}
